<?php

class admin_plugin_priv{
	/**
	 * 
	 *
	 * @param AdminController $controller
	 */
	public static function check($controller){
		if($controller->app=='admin' and $controller->controller=='login' and ($controller->action=='login' or $controller->action=='login_form')){
			return;
		}
		
		if($controller instanceof ErrorController ){
			return;
		}
		
		$controller->requireLogin();
	}
	
	public static function checkPriv($controller){
		$acl = new admin_util_acl();
		$allow = $acl->isAllowUser(AdminController::$login['uid'], $controller->app."_".$controller->controller."_".$controller->action);
		if(!$allow){
			header('location: '.AdminController::_makeURL('admin', 'user', 'no_priv'));
			exit();
		}
	}
}